<%@page import="domain.AlternativePair"%>
<%@page import="java.util.ArrayList"%>
<%@page import="domain.Alternative"%>
<%@page import="domain.Criteria"%>
<%@page import="center.DateUtil"%>
<%@page import="domain.Project"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
	String message = (String) request.getAttribute("message");
	Criteria criteria = (Criteria) request.getAttribute("criteria");
	List<Alternative> alternatives = (ArrayList<Alternative>) request.getAttribute("alternatives");
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%=criteria.getName() %>'s Preference</title>
<link href="./resources/style/mainStyle.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	window.onload = function(){
		if("<%=message%>" != "null" ){
			alert("<%=message%>");
		}
	}
</script>
</head>
<body>
<br/>
	<div align="center">
		<div class='box' style="width: 60%" align="center">
			<div class='boxtop'><div></div></div>
		  		<div class='boxcontent'>
		  			<u><%= criteria.getName()%></u>
		  			<div align="left">
			  			<form action="./preference" method="post">
						<input type="hidden" name="criteriaId" value="<%=criteria.getId() %>"/>
			  				<%if(criteria.isLeafNode()){%>
			  					<input type="hidden" name="type" value="alternative"/>
			  					<%
				  					for(int j=0; alternatives!=null && j<alternatives.size()-1; j++){
				  						Alternative mainAlter = alternatives.get(j);
				  						for(int k=j+1; k<alternatives.size(); k++){
				  							Alternative tempAlter = alternatives.get(k);
				  				%>
										<i><%= mainAlter.getName()%></i> Compare To <i><%= tempAlter.getName()%></i>
										<input type="hidden" name="subject" value="<%= mainAlter.getId()%>"/>
										<input type="hidden" name="object" value="<%= tempAlter.getId()%>"/>
										<ul>
											<li>
												<select name="preference" id="preference<%= mainAlter.getName()%><%= tempAlter.getName()%>">
													<option value="<%=mainAlter.getId() %>"><%=mainAlter.getName() %></option>
													<option value="<%=tempAlter.getId() %>"><%=tempAlter.getName() %></option>
												</select>
												is more important with 
												<select name="score" id="score<%= mainAlter.getName()%><%= tempAlter.getName()%>">
													<option value="1">Equally preferred</option>
													<option value="2">Equally to moderately</option>
													<option value="3">Moderately preferred</option>
													<option value="4">Moderately to strongly</option>
													<option value="5">Strongly preferred</option>
													<option value="6">Strongly to very strongly</option>
													<option value="7">Very strongly preferred</option>
													<option value="8">Very strongly to extremely</option>
													<option value="9">Extremely preferred</option>
												</select>
												level
											</li>
										</ul>
				  					<%} %>
				  				<%} %>
			  				<%}else{%>
			  				<input type="hidden" name="type" value="criteria"/>
			  				<%
			  					List<Criteria> subCriterias = criteria.getSubCriterias();
			  					for(int j=0; subCriterias!=null && j<subCriterias.size()-1; j++){
			  						Criteria mainSub = subCriterias.get(j);
			  						for(int k=j+1; k<subCriterias.size(); k++){
			  							Criteria tempSub = subCriterias.get(k);
			  				%>
			  							<i><%= mainSub.getName()%></i> Compare To <i><%= tempSub.getName()%></i>
			  							<input type="hidden" name="subject" value="<%= mainSub.getId()%>"/>
										<input type="hidden" name="object" value="<%= tempSub.getId()%>"/>
			  							<ul>
											<li>
												<select name="preference" id="preference">
													<option value="<%=mainSub.getId() %>"><%=mainSub.getName() %></option>
													<option value="<%=tempSub.getId() %>"><%=tempSub.getName() %></option>
												</select>
												is more important with 
												<select name="score" id="score">
													<option value="1">Equally preferred</option>
													<option value="2">Equally to moderately</option>
													<option value="3">Moderately preferred</option>
													<option value="4">Moderately to strongly</option>
													<option value="5">Strongly preferred</option>
													<option value="6">Strongly to very strongly</option>
													<option value="7">Very strongly preferred</option>
													<option value="8">Very strongly to extremely</option>
													<option value="9">Extremely preferred</option>
												</select>
												level
											</li>
										</ul>
			  						<%} %>
				  				<%} %>
			  				<%} %>
							<input class="button black" type="submit" value="Save" />
			   			</form>
		  			</div>
		  		</div>
		 	<div class='boxbottom'><div></div></div>
		</div>
	</div>
</body>
</html>